package com.ccys.app.controller;

import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.cache.UserUtil;
import com.ccys.db.dto.app.feedback.FeedbackDto;
import com.ccys.db.entity.TblBooking;
import com.ccys.db.entity.TblFeedback;
import com.ccys.db.mapper.TblFeedbackMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author：XLY
 * @Date：2024/1/26 0026
 */

@RestController
@RequestMapping("/feedbackAfterPaymentSucceed")
@Api(tags = "Feedback After Payment Succeed")
public class FeedbackController {



    @Resource
    private TblFeedbackMapper mapper;



    @ApiOperation("Feedback After Payment Succeed/ 1")
    @PostMapping("Feedback")
    @Transactional
    public ResponseResultApp feedback(@RequestBody FeedbackDto dto) {
        //{
        //    "errorCode": 0,
        //    "message": "Thank you for taking the time to provide us with your feedback. We strive towards improving our services and take your feedback seriously.",
        //    "data": null
        //}
        TblFeedback model = new TblFeedback();
        model.setBookingId(dto.getBooking_id());
        model.setContent(dto.getContent());
        String curLoginUserId = UserUtil.getCurLoginUserId();
        model.setMemId(curLoginUserId);
        mapper.insert(model);
        return ResponseResultApp.success("Thank you for taking the time to provide us with your feedback. We strive towards improving our services and take your feedback seriously.",null);
    }
}
